package online.sh.cn.fy.servlet;

import java.io.IOException;
import java.net.URLDecoder;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import online.sh.cn.fy.common.utils.ResponseUtils;
import online.sh.cn.fy.common.utils.SqlUtil;

/**
 * Servlet implementation class fycaptionArea
 */
@WebServlet("/fycaptionArea")
public class fycaptionArea extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public fycaptionArea() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		
		String shname = URLDecoder.decode(request.getParameter("shname"),"UTF-8");

		SqlUtil sqlutil= new SqlUtil();
		List<String> rs = sqlutil.getfyCaptionarea(shname);
		JSONArray json = new JSONArray();
        for(String pLog : rs){
            JSONObject jo = new JSONObject();
            jo.put("sharea", pLog);
             
            json.add(jo);
        }
		
		ResponseUtils.renderJson(response, json.toString());
	}

}
